package com.finalterm.order.feign;

import com.finalterm.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 商品服务Feign客户端
 */
@FeignClient(name = "product-service", fallback = ProductServiceClientFallback.class)
public interface ProductServiceClient {
    
    /**
     * 获取商品详情
     */
    @GetMapping("/api/product/detail/{productId}")
    Result<Object> getProductDetail(@PathVariable("productId") Long productId);
    
    /**
     * 扣减库存
     */
    @PostMapping("/api/product/stock/deduct")
    Result<Boolean> deductStock(@RequestBody Object deductDTO);
    
    /**
     * 恢复库存
     */
    @PostMapping("/api/product/stock/recover")
    Result<Boolean> recoverStock(@RequestParam("productId") Long productId,
                               @RequestParam("quantity") Integer quantity,
                               @RequestParam("orderId") String orderId);

    /**
     * 确认库存扣减
     */
    @PostMapping("/api/product/stock/confirm")
    Result<Boolean> confirmStockDeduction(@RequestParam("orderNo") String orderNo,
                                        @RequestParam("productId") Long productId,
                                        @RequestParam("quantity") Integer quantity,
                                        @RequestParam("orderStatus") String orderStatus);
}
